package com.swt.controller.T_controller;

import com.alibaba.fastjson.JSON;
import com.swt.domain.Club;
import com.swt.domain.Shop;
import com.swt.service.T_service.ShopService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
public class ShopController {
    @Resource
    private ShopService shopService;

@RequestMapping("/shopAdd")
@ResponseBody
    public String shopAdd(Shop shop, HttpServletRequest httpServletRequest){
    Club club = (Club) httpServletRequest.getSession().getAttribute("CLUB_SESSION_KEY");
    int clubClubId = club.getClubId();

    Boolean shopadd = shopService.shopaddServic(shop,clubClubId);
        return JSON.toJSONString(shopadd);
    }

    @RequestMapping("/shopQuery")
    @ResponseBody
    public String shopQuery(HttpServletRequest httpServletRequest){
        Club club = (Club) httpServletRequest.getSession().getAttribute("CLUB_SESSION_KEY");
        int clubClubId = club.getClubId();

    List<Shop> shopList = shopService.shopquery(clubClubId);
    return JSON.toJSONString(shopList);
    }

    @RequestMapping("/shopQuery2")
    @ResponseBody
    public String shopQuery2(int id,HttpServletRequest httpServletRequest){
        Club club = (Club) httpServletRequest.getSession().getAttribute("CLUB_SESSION_KEY");
        int clubClubId = club.getClubId();

        List<Shop> shopList2 = shopService.shopquery2(id,clubClubId);
        return JSON.toJSONString(shopList2);
    }

    @RequestMapping("/shopdelete")
    @ResponseBody
    public String deleteCurriculum(int id){

       boolean shopboolean = shopService.shopDelate(id);
        return JSON.toJSONString(shopboolean);

    }






    public ShopService getShopService() {

        return shopService;
    }

    public void setShopService(ShopService shopService) {
        this.shopService = shopService;
    }
}
